
import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import fire from '@feidao/web/atom/browser/msg/fire';

export default async function ca014(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	//  审核
	const c_boxs = fd.data.node.querySelectorAll('[data-feidao-name="list_checkbox"]:checked');
	if (c_boxs.length === 0) {
		fire('zj-common-002', 'ec-001', 'fail', '请选择要审核的行');
	} else {
		const stauss = Array.from(c_boxs).map((i: any) => {
			return i.closest('[data-list]').getAttribute('data-value');
		}).map((j: any) => {
			const _data = JSON.parse(j);
			console.log(_data);
			return {
				staus: _data.staus || _data.docstatus,
				_id: _data._id
				// staff_name: _data.staff_name
			};
		});
		const w = stauss.filter((i: any) => {
			return i.staus === '审核通过' || i.staus === '已审核';
		});
		// const w = stauss.filter((i: any) => {
		// 	return i.staus === '审核通过';
		// }).map((j: any) => {
		// 	return j.staff_name;
		// });
		if (w.length > 0) {
			// fire('zj-common-002', 'ec-001', 'fail', ('不能重复审核 ' + w.toString()));
			fire('zj-common-002', 'ec-001', 'fail', '不能重复审核！');
			return;
		}
		const ids = stauss.map((i: any) => {
			return i._id;
		});
		const component_no = args[0].target.getAttribute('data-return-component');
		const event_no = args[0].target.getAttribute('data-return-event');
		fire('zj-common-010', 'ec-001', { component_no, event_no, ids });
	}
}
